import { transfLonAndLat } from "@/utils/chart"
import { dateFormat } from "@/utils/date"

export const option = [
  {
    label: "船名",
    prop: "aisShipName",
  }, {
    label: "吃水",
    prop: "aisDraught",
    type: "filter",
    format: (row) => {
      if (row.aisDraught >= 0 && row.aisDraught) {
        return row.aisDraught + "米"
      } else {
        return ""
      }
    }
  }, {
    label: "MMSI",
    prop: "aisMmsi"
  }, {
    label: "船长",
    prop: "length",
    type: "filter",
    format: (row) => {
      const length = row.aisHeadLength + row.aisTailLength
      return (length >= 0 && length) ? length + "m" : "0m";
    }
  }, {
    label: "接收时间",
    prop: "time",
    type: "filter",
    format: (val) => {
      if (!val.time) {
        return ""
      } else {
        return dateFormat(new Date(parseInt(val.time) * 1000))
      }
    }
  }, {
    label: "船宽",
    prop: "width",
    type: "filter",
    format: (row) => {
      const width = row.aisLeftWidth + row.aisRightWidth
      return (width >= 0 && width) ? width + "m" : "0m";
    }
  }, {
    label: "呼号",
    prop: "aisCallsign"
  }, {
    label: "艏向",
    prop: "targetRcourse",
    type: "filter",
    format: (row) => {
      if (!row.targetRcourse || row.targetRcourse === -1) {
        return ""
      } else {
        return parseInt(row.targetRcourse) + "°"
      }
    }
  }, {
    label: "纬度",
    prop: "latitude",
    type: "filter",
    format: (row) => {
      if (!row.targetLat) {
        return ""
      } else {
        return transfLonAndLat(row.targetLat, "lat", true)
      }
    }
  }, {
    label: "经度",
    prop: "longitude",
    type: "filter",
    format: (row) => {
      if (!row.targetLon) {
        return ""
      } else {
        return transfLonAndLat(row.targetLon, "lon", true)
      }
    }
  }
]

export const initButtonState = () => {
  return {
    isWave: false,
    isLine: false,
    task: false
  }
}
